<?php
declare(strict_types=1);

namespace LowCode\Naive;

use LowCode\Naive;
use LowCode\Node;
use LowCode\Support\JsExp;
use LowCode\Traits\Props\HasDisabled;
use LowCode\Traits\Props\HasDisplayDirective;
use LowCode\Traits\Props\HasName;
use LowCode\Traits\Props\HasTitle;

/**
 * Collapse 组件
 * @method static static make(string|JsExp $title = null,  mixed $children = null) CollapseItem组件
 */
class CollapseItem extends Naive
{
    use HasName, HasTitle, HasDisabled, HasDisplayDirective;

    /**
     * @param string|JsExp|null $title
     * @param mixed|null $children
     */
    public function __construct(string|JsExp $title = null,  mixed $children = null)
    {
        parent::__construct();
        if ($title){
            $this->title($title);
        }
        $this->children($children);
    }

    /**
     * 折叠面板的自定义图标 设置 slot arrow 内容
     * (props: { collapsed: boolean })
     * @param Node $node
     * @param array $params ['collapsed']
     * @return $this
     */
    public function slotArrow(Node $node, array $params = ['collapsed']): static
    {
        return $this->addSlot($node, 'arrow', $params);
    }

    /**
     * 设置 slot header 内容
     * (props: { collapsed: boolean })
     * @param Node $node
     * @param array $params ['collapsed']
     * @return $this
     */
    public function slotHeader(Node $node, array $params = ['collapsed']): static
    {
        return $this->addSlot($node,'header', $params);
    }

    /**
     * 设置 slot header-extra 内容
     * (props: { collapsed: boolean })
     * @param Node $node
     * @param array $params ['collapsed']
     * @return $this
     */
    public function slotHeaderExtra(Node $node, array $params = ['collapsed']): static
    {
        return $this->addSlot($node,'header-extra', $params);
    }
}
